<script type="text/javascript">
	function doSearchParams(value) {
		
	}
	
	//表格查询  
	function reloadParams() {
		var params = params_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		params_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		params_list.datagrid('unselectAll');
		params_list.datagrid('uncheckAll');
	}


	function addParams() {
		createFromWindow("新增信息", "params.do?editParams", "params.do?saveParams",
				function(data) {
					printLog(data);
					reloadParams();
				});
// 		$.ajax( {  
//             type : 'GET',    
//             url : 'params.do?saveParams',     
//             async: false,//禁止ajax的异步操作，使之顺序执行。  
//             dataType : 'json',  
//             success : function(data,textStatus){  
//                 alert(data.msg);  
//             },  
//             error : function(data,textstatus){  
//                 alert(data.responseText);  
//             }  
//         }); 
		
// 		jmaxAjax('params.do?saveParams','123',function(data) {
// 			alert(data);
// 		});
	}
	
	function deleteParams() {
		var rows = params_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('params.do?deleteParamsItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadParams();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editParams() {
		var rows = params_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("编辑信息", "params.do?editParams&paramsId=" + rows[0].id,
					"params.do?saveParams", function(data) {
						reloadParams();
					},true);
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	
	//操作按钮触发
	function operationsLookParams(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = params_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("查看信息", "params.do?editParams&paramsId=" + id,
					null, null,false);
		} else {
			showMsg('请选择查看记录.');
		}
	}
	
	function operationsEditParams(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = params_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("编辑信息", "params.do?editParams&paramsId=" + id,
					"params.do?saveParams", function(data) {
						reloadParams();
					},true);
		} else {
			showMsg('请选择编辑记录.');
		}
	}
	
	function operationsSendParams() {
		printLog('发送');
	}
	
	function operationsDeleteParams(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = new_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			$.messager.confirm('询问', '你确认要删除吗?', function(r) {
				if (r) {
					$.post('params.do?deleteParamsItems', {
						ids : id
					}, function(result) {
						if (result.success) {
							reloadParams(); 
						}
						showMsg(result.msg);
					}, 'json');
				}
			});
		} else {
			showMsg("请选择操作记录.");
		}
	}
	
	function clearParamsSearch() {
		setGridSearchParams('params_list','paramsSearchForm',true,reloadParams);
	}
	
	//根据条件查询
	function paramsSearch() {
		setGridSearchParams('params_list','paramsSearchForm',false,reloadParams);
	}
</script>

<#assign operations = "[\{shiro:'sys:params:refresh',onClick:'operationsLookParams',src:'static/jmax/images/notes/note.png',title:'查看'},
	   					\{shiro:'sys:params:edit',onClick:'operationsEditParams',src:'static/jmax/images/notes/note_edit.png',title:'编辑'},
	   					\{shiro:'sys:params:delete',onClick:'operationsDeleteParams',src:'static/jmax/images/notes/note_delete.png',title:'删除'}
	  				   ]"/>

<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		
		<@eu.datagrid id="params_list" toolbar="#paramslist_search" idField="id" operations="${operations!}"
			 url="params.do?loadList" rownumbers="true"
			 item="com.xdtech.sys.vo.ParamsItem"/>
		
		<div id="paramslist_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
<!-- 				<form id="paramsSearchForm"> -->
<!-- 					<table> -->
<!-- 						<tr> -->
<!-- 							<td>XXX：</td> -->
<!-- 							<td><input type="text" name="XXX" style="width: 150px" /></td> -->
<!-- 							<td> -->
<!-- 								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="paramsSearch()"/> -->
<!-- 	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearParamsSearch()"/> -->
<!--  					 		</td> -->
<!-- 						</tr> -->
<!-- 					</table> -->
<!-- 				</form> -->
				
			</div>
			<div id="params_toolbar" style="height: auto">
				<@eu.linkbutton showName="新增" shiro="sys:params:add" iconCls="icon-add" onclick="addParams()"/>
				<@eu.linkbutton showName="删除" shiro="sys:params:delete" iconCls="icon-remove" onclick="deleteParams()"/>
				<@eu.linkbutton showName="编辑" shiro="sys:params:edit" iconCls="icon-edit" onclick="editParams()"/>
				<@eu.linkbutton showName="刷新" shiro="sys:params:refresh" iconCls="icon-reload" onclick="reloadParams()"/>
				
			</div>
		</div>
	</div>
</div>